import java.util.Arrays;

public class Algorithm {

    /*public static int binarySearch(int[] arr, int k) {
        int l = 0,r  = arr.length - 1;
        while (l <= r) {
            int mid = l + ((r - l) >>> 1);
            if (arr[mid] > k) {
                r = mid - 1;
            } else if (arr[mid] < k) {
                l = mid + 1;
            } else  {
                return mid;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,9};
        int index = binarySearch(arr,9);
        if (index >= 0) {
            System.out.println("find it in " + (index + 1));
        } else {
            System.out.println("cant find");
        }
    }
     */


    /*public static boolean isUpper(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            if (arr[i + 1] <= arr[i]) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        int[] arr = {1,5,7,9,2,3};
        boolean res = isUpper(arr);
        if (res) {
            System.out.println("It's up!");
        } else {
            System.out.println("It's not up!!!!");
        }
    }

     */

    /*public static void bubbleSort(int[] arr) {
        boolean flag = true;
        for (int i = 0; i < arr.length; i++) {
            flag = true;
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int t = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = t;
                    flag = false;
                }
            }
            if (flag) {
                break;
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = {2,1,3,7,5,4,6};
        bubbleSort(arr);
        System.out.println(Arrays.toString(arr));
    }

     */

    public static int findTheOnlyOne(int[] arr) {
        int ret = 0;
        for (int i : arr) {
            ret ^= i;
        }
        return ret;
    }

    public static void main(String[] args) {
        int[] arr = {-1,-3,-3,-1,1,1,2,5,5,6,6,8,8,};
        int res = findTheOnlyOne(arr);
        System.out.println(res + " appears only once");
    }

    /*
     // Encodes a tree to a single string.
    public String serialize(TreeNode root) {
        return process1(root, "");
    }

    public String process1(TreeNode root, String res) {
        if (root == null) {
            res += "null,";
        } else {
            res += res.valueOf(root.val) + ",";
            res = process1(root.left, res);
            res = process1(root.right, res);
        }
        return res;
    }

    // Decodes your encoded data to tree.
    public TreeNode deserialize(String data) {
        String[] str = data.split(",");
        List<String> list = new ArrayList<String>(Arrays.asList(str));
        return process2(list);
    }

    public TreeNode process2(List<String> list) {
        if (list.get(0).equals("null")) {
            list.remove(0);
            return null;
        }
        TreeNode head = new TreeNode(Integer.valueOf(list.get(0)));
        list.remove(0);
        head.left = process2(list);
        head.right = process2(list);
        return head;
    }
     */
}
